package com.javaGather.demo3;

import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;

public class Test5 {
    public static void main(String[] args) {
        /**
         * HashSet 底层基于HashMap实现，不会重复 ，无序
         * LinkedHashSet   不会重复，有序
         */
//        HashSet<String> strings = new HashSet<>();
//        for (int i = 0; i < 100; i++) {
//            strings.add("" + i);
//        }
//        Iterator<String> iterator = strings.iterator();
//        while (iterator.hasNext()) {
//            System.out.println(iterator.next());
//        }


        LinkedHashSet<String> strings1 = new LinkedHashSet<>();
        for (int i = 0; i < 100; i++) {
            strings1.add("" + i);
        }
        Iterator<String> iterator1 = strings1.iterator();
        while (iterator1.hasNext()) {
            System.out.println(iterator1.next());
        }


    }
}
